<!doctype html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>后台管理</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="/resource/backend/css/font.css">
    <link rel="stylesheet" href="/resource/backend/css/weadmin.css">
    <script type="text/javascript" src="/resource/backend/lib/layui/layui.js" charset="utf-8"></script>

</head>

<body>
<!-- 顶部开始 -->
<div class="container">
    <div class="logo">
        <a href='${ backend_url "/"  }$'>后台管理系统</a>
    </div>
    <div class="left_open">
        <i title="展开左侧栏" class="iconfont">&#xe699;</i>
    </div>
    <ul class="layui-nav left fast-add" lay-filter="">
        ${if .can.manage }$
        <li class="layui-nav-item">
            <a href="javascript:;">快捷方式</a>
            <dl class="layui-nav-child">
                <!-- 快捷方式列表 -->
                ${ if .shortcutList|len }$
                ${ range $key,$item:=.shortcutList }$
                <dd>
                    <a onclick="WeAdminShow('${ $item.Name }$','${ $item.Route }$')">${ $item.Name }$</a>
                </dd>
                ${ end }$
                ${ else }$
                <dd><a href="javascript:;">暂无快捷方式</a></dd>
                ${ end }$
            </dl>
        </li>
        ${ end }$
    </ul>
    <ul class="layui-nav right" lay-filter="">
        <li class="layui-nav-item">
            <a href="javascript:;">${ .admin_session.Name }$</a>
            <dl class="layui-nav-child">
                <!-- 二级菜单 -->
                <dd>
                    <a href="javascript:;" class="logout" data-href='${ backend_api_url "/admin/logout"  }$'>退出</a>
                </dd>
            </dl>
        </li>
        <li class="layui-nav-item">
            <a href="javascript:;" id="clearCache">清理缓存</a>
        </li>
        <li class="layui-nav-item to-index">
            <a href="/" target="_blank">前台首页</a>
        </li>
    </ul>

</div>
<!-- 顶部结束 -->
<!-- 中部开始 -->
<!-- 左侧菜单开始 -->
<div class="left-nav">
    <div id="side-nav">
        <ul id="nav">
            ${range $key, $item := .backend_menu}$
            <li>
                <a href="javascript:;">
                    <i class="iconfont"></i>
                    <cite>${$item.Title}$</cite>
                    <i class="iconfont nav_right">&#xe697;</i>
                </a>
                <ul class="sub-menu">
                    ${range $key, $subItem := $item.Children}$
                    <li>
                        <a _href='${$subItem.Route | backend_url}$'>
                            <i class="iconfont">&#xe6a7;</i>
                            <cite>${$subItem.Title}$</cite>
                        </a>
                    </li>
                    ${end}$
                </ul>
            </li>
            ${end}$
        </ul>
    </div>
</div>
<!-- <div class="x-slide_left"></div> -->
<!-- 左侧菜单结束 -->
<!-- 右侧主体开始 -->
<div class="page-content">
    <div class="layui-tab tab layui-this" lay-filter="wenav_tab" id="WeTabTip" lay-allowclose="true">
        <ul class="layui-tab-title" id="tabName">
            <li id="welcome">系统信息</li>
        </ul>
        <div class="layui-tab-content">
            ${ if dry_run }$
            <div id="dry_run" style="overflow: hidden">
                <blockquote class="layui-elem-quote" style="border-left: 5px solid #ff5722;">
                    空跑模式已开启，数据只读，无法保存！！！
                </blockquote>
            </div>
            <script>
                setTimeout(function () {
                    layui.$('#dry_run').animate({'height': 0}, 2000);
                }, 2000)
            </script>
            ${ end }$
            <div class="layui-tab-item layui-show">
                <iframe src='${ backend_url "/welcome/index" }$' frameborder="0" scrolling="yes"
                        class="weIframe"></iframe>
            </div>
        </div>
    </div>
</div>
<div class="page-content-bg"></div>
<!-- 右侧主体结束 -->
<!-- 中部结束 -->
<!-- 底部开始 -->
<div class="footer">
    <div class="copyright">Copyright ©${ .|date "Y" }$ All Rights Reserved &emsp;${ system_setting "web_name" }$</div>
</div>
<!-- 底部结束 -->
<script type="text/javascript">
    //			layui扩展模块的两种加载方式-示例
    //		    layui.extend({
    //			  admin: '{/}../.__STATIC__/admin/js/admin' // {/}的意思即代表采用自有路径，即不跟随 base 路径
    //			});
    //			//使用拓展模块
    //			layui.use('admin', function(){
    //			  var admin = layui.admin;
    //			});
    layui.config({
        base: '/resource/backend/js/'
        , version: '101100'
    });

    layui.use(['admin', 'jquery', 'layer'], function () {
        var admin = layui.admin;
        var $ = layui.jquery;
        var layer = layui.layer;
        $('#clearCache').click(function () {
            layer.confirm('确定清理所有缓存？', {
                btn: ['确定', '取消']
                , yes: function () {
                    //ajax清理缓存
                    $.post('${ backend_api_url "/admin/clear_cache" }$', function (res) {
                        //console.log(res)
                        if (res['code'] === 0) {
                            layer.msg(res['message'], {
                                icon: 6
                                , time: 1000
                            });
                        } else {
                            layer.msg(res['message'], {
                                icon: 5
                                , time: 2000
                            });
                        }
                    });
                }
            });
        });
        //退出登录
        $('.logout').click(function () {
            $.post('${ backend_api_url "/admin/logout" }$', function () {
                top.location.reload()
            })
        });

        //查询是否有未处理留言数量
        function getUntreated() {
            //未处理留言弹层数量
            var layerLen = $('#untreatedGuestbook').length;
            var layerBody = $('#untreatedGuestbook').parent();
            $.get("{:url('admin/guestbook/getuntreated')}", function (res) {
                //console.log('未处理的留言'+res);
                var w = document.body.offsetWidth;
                var h = document.body.offsetHeight;
                if (res > 0) {
                    if (layerLen != 0) {
                        //已经存在弹窗，修改数值
                        $('#guestBooksNum').text(res);
                    } else {
                        //创建弹窗
                        var index = layer.open({
                            type: 1
                            ,
                            id: 'untreatedGuestbook'
                            ,
                            title: false
                            ,
                            anim: 4
                            ,
                            skin: 'layui-layer-molv'
                            ,
                            offset: [h - 150 + 'px', w - 240 + 'px']
                            ,
                            content: '<div style="padding: 20px 40px 0 40px;">您有 <b id=\'guestBooksNum\' style=\'color:red;\'>' + res + '</b> 条新留言未处理</div>'
                            ,
                            btn: '立即处理'
                            ,
                            btnAlign: 'c' //按钮居中
                            ,
                            shade: 0 //不显示遮罩
                            ,
                            yes: function () {
                                WeAdminShow('留言列表', "{:url('admin/guestbook/index')}")
                            }
                        });
                    }
                } else {
                    layerBody.remove();
                }
            });

        }

        // getUntreated();
        // //1分钟查询一次留言
        // setInterval(function () {
        //     getUntreated();
        // }, 60000);

    });
</script>
</body>
<!--Tab菜单右键弹出菜单-->
<ul class="rightMenu" id="rightMenu">
    <li data-type="fresh">刷新</li>
    <li data-type="current">关闭当前</li>
    <li data-type="other">关闭其它</li>
    <li data-type="all">关闭所有</li>
</ul>
</html>
